import request from '@/utils/request'

export function list(query) {
  return request({
    url: '/admin/v1/generator/list',
    method: 'get',
    params: query
  })
}

export function dbList(query) {
  return request({
    url: '/admin/v1/generator/db/list',
    method: 'get',
    params: query
  })
}

export function detail(id) {
  return request({
    url: `/admin/v1/generator/${id}`,
    method: 'get'
  })
}

export function columnList(id, query) {
  return request({
    url: `/admin/v1/generator/column/${id}`,
    method: 'get',
    params: query
  })
}

export function importTableSave(data) {
  return request({
    url: `/admin/v1/generator/importTable`,
    method: 'post',
    data
  })
}

export function update(data) {
  return request({
    url: `/admin/v1/generator/editSave`,
    method: 'put',
    data
  })
}

export function updateBatch(data) {
  return request({
    url: `/admin/v1/generator/updateBatch`,
    method: 'put',
    data
  })
}

export function del(data) {
  return request({
    url: '/admin/v1/generator/remove',
    method: 'delete',
    data
  })
}

export function download(tableName) {
  return request({
    url: `/admin/v1/generator/download/${tableName}`,
    method: 'get',
    responseType: 'blob'
  })
}

export function genCode(tableName) {
  return request({
    url: `/admin/v1/generator/genCode/${tableName}`,
    method: 'get'
  })
}

export function synchDb(tableName) {
  return request({
    url: `/admin/v1/generator/synchDb/${tableName}`,
    method: 'get'
  })
}

export function batchGenCode(query) {
  return request({
    url: `/admin/v1/generator/batchGenCode`,
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

export function configInfo() {
  return request({
    url: `/admin/v1/generator/config/info`,
    method: 'get'
  })
}

export function configAdd(data) {
  return request({
    url: `/admin/v1/generator/config/add`,
    method: 'post',
    data
  })
}
